{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "4fda52f8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 1.9803921568627452\n",
      "2 1.4975369458128078\n",
      "3 1.4281690140845071\n",
      "4 1.4165981922760889\n",
      "5 1.4146224146224147\n",
      "6 1.4142837019298493\n",
      "7 1.4142255961713013\n",
      "8 1.4142156270391764\n",
      "9 1.414213916613577\n",
      "10 1.4142136231511468\n",
      "11 1.41421357280096\n"
     ]
    }
   ],
   "source": [
    "def calXnew(Xold):\n",
    "    return (2*Xold +2)/(Xold+2)\n",
    "Xold = 100\n",
    "Xnew = 0\n",
    "i = 0\n",
    "\n",
    "while True > 0.0000001:\n",
    "    Xnew = calXnew(Xold)\n",
    "    difference = abs(Xnew - Xold)\n",
    "    Xold = Xnew\n",
    "    i += 1\n",
    "    print(i,Xnew)\n",
    "    if difference < 0.0000001:\n",
    "        break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "573f47d0",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
